using Digitalmes.Domain.Entities.Mes.Equipments;

namespace Digitalmes.Application.Mes.Equipments.Inspections.Queries;

/// <summary>
/// 手动点检项查询命令。
/// </summary>
/// <param name="PlanId">点检计划 Id</param>
public sealed record GetManualInspectionItemListQuery(long PlanId) : IRequest<IResult<List<EquipManualInspectionItemDto>>>;

internal sealed class GetManualInspectionItemListQueryHandler(IRepository<EquipManualInspectionItem> repo)
    : IRequestHandler<GetManualInspectionItemListQuery, IResult<List<EquipManualInspectionItemDto>>>
{
    public async Task<IResult<List<EquipManualInspectionItemDto>>> Handle(GetManualInspectionItemListQuery request, CancellationToken cancellationToken)
    {
        var items = await repo.GetListAsync(m => m.PlanId == request.PlanId, cancellationToken);
        return Result.From(items.Adapt<List<EquipManualInspectionItemDto>>());
    }
}

